home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 13317 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.6 KB  |  40 lines

  1. Newsgroups: comp.os.ms-windows.programmer.graphics,comp.lang.c++
  2. Path: nntp.coast.net!torn!nott!emr1!jagrant
  3. From: jagrant@emr1.emr.ca (John Grant)
  4. Subject: Re: Drawing from any procedure
  5. Message-ID: <DosooJ.1uI@emr1.emr.ca>
  6. Organization: Energy, Mines, and Resources, Ottawa
  7. References: <4iuni1$oep@lily.csv.warwick.ac.uk>
  8. Date: Sun, 24 Mar 1996 23:17:07 GMT
  9.  
  10. In article <4iuni1$oep@lily.csv.warwick.ac.uk> esuvx@csv.warwick.ac.uk (Adge) writes:
  11. >
  12. >I am programming in ms Visual C++ v.4.0 under Win95, and am trying to 
  13. >persuade it to allow me to draw graphics to a window from a procedure other
  14. >than OnPaint or OnDraw.
  15. >
  16. >I have tried using CPaintDC(this); , but this gives an access violation.
  17. >
  18. >It used to be possible under Borland Pascal for win but I can't work out
  19. >how to do it under visc++
  20. >
  21. >Can anyone help ?
  22.     If you respond to WM_PAINT, then you are provided with an HDC
  23.     (presumably your OnPaint does the BeginPaint/EndPaint stuff for you).
  24.  
  25.     If you wish to draw at any other time, you need to obtain an HDC,
  26.     i.e. with GetDC(). Do your drawing and then ReleaseDC().
  27.  
  28.     However, there is a very good reason for doing *ALL* of your drawing
  29.     at WM_PAINT. Consider what happens if you draw something anytime you
  30.     want (i.e. not at WM_PAINT).  Your picture looks fine, right?  Ok,
  31.     now what happens if your app is covered/uncovered by a dialog box
  32.     or another app? That generates WM_PAINT and you will draw part of
  33.     the picture, but not the part that you drew separately.  Remember
  34.     that you must be prepared to paint any or all of your picture at
  35.     any time at WM_PAINT.
  36. -- 
  37. John A. Grant                        jagrant@emr1.emr.ca
  38. Airborne Geophysics
  39. Geological Survey of Canada, Ottawa
  40.